package command

import (
	"time"

	"ssnotify/common/dto"
	"ssnotify/internal/notify/models"
)

type NotifyTemplateAddReq struct {
	Id      string `json:"id" comment:"通知模板id" vd:"len($)>0"`
	Name    string `json:"name" comment:"模板名" vd:"len($)>0"`
	Type    string `json:"type" comment:"通知类型" vd:"len($)>0"`
	Content string `json:"content" comment:"模板内容"`
	dto.UserInfo
}

func (s *NotifyTemplateAddReq) Generate(model *models.NotifyTemplate) {
	model.Id = s.Id
	model.Name = s.Name
	model.Type = s.Type
	model.Content = s.Content
	model.CreatorId = s.UserId
	model.AgencyId = s.AgencyId
	now := dto.LocalTime(time.Now())
	model.CreateTime = &now
}

type NotifyTemplateModReq struct {
	Id      string `json:"id" comment:"通知模板id" vd:"len($)>0"`
	Name    string `json:"name" comment:"模板名称"`
	Type    string `json:"type" comment:"模板类型"`
	Content string `json:"content" comment:"模板内容"`
	dto.UserInfo
}

func (d *NotifyTemplateModReq) Generate(model *models.NotifyTemplate) {
	if len(d.Name) > 0 {
		model.Name = d.Name
	}
	if len(d.Type) > 0 {
		model.Type = d.Type
	}
	if len(d.Content) > 0 {
		model.Content = d.Content
	}
	model.CreatorId = d.UserId
	model.AgencyId = d.AgencyId
	now := dto.LocalTime(time.Now())
	model.UpdateTime = &now
}

type NotifyTemplateDelReq struct {
	Ids []string `form:"ids" json:"ids"`
	dto.UserInfo
}

type AliSmsTemplateAddReq struct {
	Name    string `json:"name" comment:"短信模板名" vd:"len($)>0"`
	Content string `json:"content" comment:"短信模板内容" vd:"len($)>0"`
}

type AliSmsTemplateDelReq struct {
	TemplateId string `json:"templateId" comment:"短信模板Code" vd:"len($)>0"`
}
